package Text_73;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Code {

	public static void main(String[] args) {
		ArrayList<String> boylist = new ArrayList<>();
        ArrayList<String> girllist = new ArrayList<>();
        Collections.addAll(boylist,"男生一,11","男二,22","男生三,33","男四,44","男生五,55","男生六,66");
        Collections.addAll(girllist,"杨生,11","杨素,22","双儿,33","黄蓉,44","小龙女,55","杨杨,66");
        //过滤出名字是三个字的前两人
        Stream<String> newboy = boylist.stream().filter(s -> s.split(",")[0].length() == 3).limit(2);
        //过滤出姓杨的，并且不要第一个
        Stream<String> newgirl = girllist.stream().filter(s -> s.split(",")[0].startsWith("杨")).skip(1);
        //放入Actor对象中
        List<Actor> collect = Stream.concat(newboy, newgirl).map(new Function<String, Actor>() {
            public Actor apply(String s) {
                String name = s.split(",")[0];
                int age = Integer.parseInt(s.split(",")[1]);
                return new Actor(name, age);
            }
        }).collect(Collectors.toList());
        //化简
        //Stream.concat(newboy,newgirl)
        // .map( s->new Actor(s.split(",")[0],
        // Integer.parseInt(s.split(",")[1])))
        // .collect(Collectors.toList());
        System.out.println(collect);

	}

}
